<template>
	<div>
		<!-- <bbsInfoDetail :bbsInfo="bbsInfos" :userInfo="userInfos"></bbsInfoDetail> -->
		<el-table :data="empInfo" height="700" border style="width: 100%;">
			<el-table-column prop="empid" label="员工id" width="150">
			</el-table-column>

			<el-table-column prop="empname" label="员工姓名" width="150">
			</el-table-column>
			<el-table-column prop="empstate" label="员工状态" width="150">
			</el-table-column>
			<el-table-column prop="emptype" label="员工身份">
			</el-table-column>
			<el-table-column label="操作" width="250" fixed="right">
				<template slot-scope="scope">
					<el-button @click="handleClick(scope.row)" type="text" size="small" icon="el-icon-document">详情</el-button>
					<!-- <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button> -->
				</template>
			</el-table-column>
		</el-table>
		<!-- <mealInfoadd></mealInfoadd> -->
		<staffInfoDetail :empInfo="empInfos"></staffInfoDetail>
		<!-- 	<bbsInfoDetail :bbsInfo="bbsInfos"></bbsInfoDetail> -->
		<staffInfoAdd></staffInfoAdd>
	</div>
</template>
<script>
	// import mealInfoDetail from '@/components/meal_info/Meal_info_detail.vue'
	// import mealInfoadd from '@/components/meal_info/Meal_info_add.vue'
	import staffInfoDetail from '@/components/staff_info/Staff_info_detail.vue'
	import staffInfoAdd from '@/components/staff_info/Staff_info_add.vue'

	import {
		request
	} from "network/request.js"

	export default {
		components: {
			staffInfoAdd,
			staffInfoDetail
		},
		data() {
			return {
				userInfos: '',
				empInfos: '',
				empInfo: [{
					"empid": 0,
					"empname": "string",
					"empremark": "string",
					"empstate": "string",
					"emptype": "string"
				}]
			}
		},
		methods: {
			handleClick(row) {
				// console.log(row.empid)
				request({
					url: '/Emp/empInfo',
					method: 'get',
					params: {
						// id:this.$store.state.mealid
						empid: row.empid
					}
				}).then(res => {
					let emptypes = ["长期服务", "短期服务"];
					request({
						url: '/Meal/majorMeals',
						method: 'get',
					}).then(res1 => {
						res1.data.forEach(s => {
							if (res.data.emptype == s.majormealid.toString()) {
								res.data.emptype = s.majormealremark
							}
						})
						if (res.data.emptype == "A") {
							res.data.emptype = "长期服务"
						} else if (res.data.emptype == "B") {
							res.data.emptype = "短期服务"
						}
						this.empInfos = res.data
						this.$store.commit("updateStaffInfoflag", true)
					})
				})

			}
		},
		created() {
			request({
				url: '/Emp/empInfos',
				method: 'get'
			}).then(res => {
				// console.log(res.data)

				if (res.data.length > 0) {
					res.data = res.data.filter(item => item.empstate != '3')
					res.data.forEach(s => {
						/*********empstate************/

						if (s.empstate == '0') {
							s.empstate = "休假"
						} else if (s.empstate == '1') {
							s.empstate = "忙碌"
						} else if (s.empstate == '2') {
							s.empstate = "就绪"
						}
						/*********emptype************/
						if (s.emptype == "A") {
							s.emptype = "长期服务"
						} else if (s.emptype == "B") {
							s.emptype = "短期服务"
						} else {
							// console.log(Number(s.emptype))
							request({
								url: '/Meal/majorMeal',
								method: 'get',
								params: {
									// id:this.$store.state.mealid
									id: Number(s.emptype)
								}
							}).then(res1 => {
								s.emptype = res1.data.majormealremark
							})
						}
					})
				}
				this.empInfo = res.data
			})
		}

	}
</script>
<style>
	el-table-column {
		height: 50px;
	}

	.el-main {
		line-height: 20px;
	}
</style>
